<?php
/**
 * 注：此模板为自动生成模板，需要根据实际情况调整修改
 * 此模板对 无主键/单一主键 表的支持较好，联合主键表在下一版本开发
 */
namespace Data;

use Utils\MyException;

class Restaurant {

    //数组
    private $array;


    public function __construct ($array){

        $this->array = $array;

        self::setDefault();

    }

    public function getArray() {
        return $this->array;
    }

    public function updateWithArray($array) {
        foreach($array as $key=>$value)
        {
            if(array_key_exists($key,$this->array))
            {
                $this->array = array_merge($this->array,array($key=>$value));
            }
        }
    }



    private function setDefault(){

        if(count($this->array)==0){
            self::setRESTAURANT_ID("null");
            self::setWX_ID("");
            self::setIMG_URL("");
            self::setRESTAURANT_NAME("");
            self::setDESCRIPTION("");
            self::setANNOUNCEMENT("");
            self::setIS_OPENING("0");
            self::setOPENING_TIME("");
            self::setCONTACT_NAME("");
            self::setCONTACT_NUMBER("");
            self::setPASSWORD("");
            self::setPROVINCE("");
            self::setCITY("");
            self::setCOUNTY("");
            self::setDETAIL("");
            self::setLNG("0");
            self::setLAT("0");
            self::setFOOD_GROUPS_ORDER("");
            self::setIS_ISLAMIC("0");
            self::setCREATED_ON("");
            self::setCREATED_BY("0");
            self::setUPDATED_ON("");
            self::setUPDATED_BY("0");

        }
    }






    public function setRESTAURANT_ID($value) {
        $this->array = array_merge ($this->array,array(
            'RESTAURANT_ID' => $value));
    }
    public function getRESTAURANT_ID(){

        return $this->array ['RESTAURANT_ID'];
    }


    public function setWX_ID($value) {
        $this->array = array_merge ($this->array,array(
            'WX_ID' => $value));
    }
    public function getWX_ID(){

        return $this->array ['WX_ID'];
    }


    public function setIMG_URL($value) {
        $this->array = array_merge ($this->array,array(
            'IMG_URL' => $value));
    }
    public function getIMG_URL(){

        return $this->array ['IMG_URL'];
    }


    public function setRESTAURANT_NAME($value) {
        $this->array = array_merge ($this->array,array(
            'RESTAURANT_NAME' => $value));
    }
    public function getRESTAURANT_NAME(){

        return $this->array ['RESTAURANT_NAME'];
    }


    public function setDESCRIPTION($value) {
        $this->array = array_merge ($this->array,array(
            'DESCRIPTION' => $value));
    }
    public function getDESCRIPTION(){

        return $this->array ['DESCRIPTION'];
    }


    public function setANNOUNCEMENT($value) {
        $this->array = array_merge ($this->array,array(
            'ANNOUNCEMENT' => $value));
    }
    public function getANNOUNCEMENT(){

        return $this->array ['ANNOUNCEMENT'];
    }


    public function setIS_OPENING($value) {
        $this->array = array_merge ($this->array,array(
            'IS_OPENING' => $value));
    }
    public function getIS_OPENING(){

        return $this->array ['IS_OPENING'];
    }


    public function setOPENING_TIME($value) {
        $this->array = array_merge ($this->array,array(
            'OPENING_TIME' => $value));
    }
    public function getOPENING_TIME(){

        return $this->array ['OPENING_TIME'];
    }


    public function setCONTACT_NAME($value) {
        $this->array = array_merge ($this->array,array(
            'CONTACT_NAME' => $value));
    }
    public function getCONTACT_NAME(){

        return $this->array ['CONTACT_NAME'];
    }


    public function setCONTACT_NUMBER($value) {
        $this->array = array_merge ($this->array,array(
            'CONTACT_NUMBER' => $value));
    }
    public function getCONTACT_NUMBER(){

        return $this->array ['CONTACT_NUMBER'];
    }


    public function setPASSWORD($value) {
        $this->array = array_merge ($this->array,array(
            'PASSWORD' => $value));
    }
    public function getPASSWORD(){

        return $this->array ['PASSWORD'];
    }


    public function setPROVINCE($value) {
        $this->array = array_merge ($this->array,array(
            'PROVINCE' => $value));
    }
    public function getPROVINCE(){

        return $this->array ['PROVINCE'];
    }


    public function setCITY($value) {
        $this->array = array_merge ($this->array,array(
            'CITY' => $value));
    }
    public function getCITY(){

        return $this->array ['CITY'];
    }


    public function setCOUNTY($value) {
        $this->array = array_merge ($this->array,array(
            'COUNTY' => $value));
    }
    public function getCOUNTY(){

        return $this->array ['COUNTY'];
    }


    public function setDETAIL($value) {
        $this->array = array_merge ($this->array,array(
            'DETAIL' => $value));
    }
    public function getDETAIL(){

        return $this->array ['DETAIL'];
    }


    public function setLNG($value) {
        $this->array = array_merge ($this->array,array(
            'LNG' => $value));
    }
    public function getLNG(){

        return $this->array ['LNG'];
    }


    public function setLAT($value) {
        $this->array = array_merge ($this->array,array(
            'LAT' => $value));
    }
    public function getLAT(){

        return $this->array ['LAT'];
    }


    public function setFOOD_GROUPS_ORDER($value) {
        $this->array = array_merge ($this->array,array(
            'FOOD_GROUPS_ORDER' => $value));
    }
    public function getFOOD_GROUPS_ORDER(){

        return $this->array ['FOOD_GROUPS_ORDER'];
    }


    public function setIS_ISLAMIC($value) {
        $this->array = array_merge ($this->array,array(
            'IS_ISLAMIC' => $value));
    }
    public function getIS_ISLAMIC(){

        return $this->array ['IS_ISLAMIC'];
    }


    public function setCREATED_ON($value) {
        $this->array = array_merge ($this->array,array(
            'CREATED_ON' => $value));
    }
    public function getCREATED_ON(){

        return $this->array ['CREATED_ON'];
    }


    public function setCREATED_BY($value) {
        $this->array = array_merge ($this->array,array(
            'CREATED_BY' => $value));
    }
    public function getCREATED_BY(){

        return $this->array ['CREATED_BY'];
    }


    public function setUPDATED_ON($value) {
        $this->array = array_merge ($this->array,array(
            'UPDATED_ON' => $value));
    }
    public function getUPDATED_ON(){

        return $this->array ['UPDATED_ON'];
    }


    public function setUPDATED_BY($value) {
        $this->array = array_merge ($this->array,array(
            'UPDATED_BY' => $value));
    }
    public function getUPDATED_BY(){

        return $this->array ['UPDATED_BY'];
    }


    public function toInsertCSV() {
        $str="";

        // RESTAURANT_ID
        $str .= self::getRESTAURANT_ID().",";
        // WX_ID
        $str .= "'". self::getWX_ID()."',";
        // IMG_URL
        $str .= "'". self::getIMG_URL()."',";
        // RESTAURANT_NAME
        $str .= "'". self::getRESTAURANT_NAME()."',";
        // DESCRIPTION
        $str .= "'". self::getDESCRIPTION()."',";
        // ANNOUNCEMENT
        $str .= "'". self::getANNOUNCEMENT()."',";
        // IS_OPENING
        $str .= "'". self::getIS_OPENING()."',";
        // OPENING_TIME
        $str .= "'". self::getOPENING_TIME()."',";
        // CONTACT_NAME
        $str .= "'". self::getCONTACT_NAME()."',";
        // CONTACT_NUMBER
        $str .= "'". self::getCONTACT_NUMBER()."',";
        // PASSWORD
        $str .= "'". self::getPASSWORD()."',";
        // PROVINCE
        $str .= "'". self::getPROVINCE()."',";
        // CITY
        $str .= "'". self::getCITY()."',";
        // COUNTY
        $str .= "'". self::getCOUNTY()."',";
        // DETAIL
        $str .= "'". self::getDETAIL()."',";
        // LNG
        $str .= "'". self::getLNG()."',";
        // LAT
        $str .= "'". self::getLAT()."',";
        // FOOD_GROUPS_ORDER
        $str .= "'". self::getFOOD_GROUPS_ORDER()."',";
        // IS_ISLAMIC
        $str .= "'". self::getIS_ISLAMIC()."',";
        // CREATED_ON
        $str .= "now()" . ",";

        // CREATED_BY
        $str .= "'". self::getCREATED_BY()."',";
        // UPDATED_ON
        $str .= "now()" . ",";

        // UPDATED_BY
        $str .= "'". self::getUPDATED_BY()."'";
        return $str;
    }



    public function toUpdateSet() {
        $str="";

        // WX_ID
        $str.= '`WX_ID` = "' . self::getWX_ID() . '",';

        // IMG_URL
        $str.= '`IMG_URL` = "' . self::getIMG_URL() . '",';

        // RESTAURANT_NAME
        $str.= '`RESTAURANT_NAME` = "' . self::getRESTAURANT_NAME() . '",';

        // DESCRIPTION
        $str.= '`DESCRIPTION` = "' . self::getDESCRIPTION() . '",';

        // ANNOUNCEMENT
        $str.= '`ANNOUNCEMENT` = "' . self::getANNOUNCEMENT() . '",';

        // IS_OPENING
        $str.= '`IS_OPENING` = "' . self::getIS_OPENING() . '",';

        // OPENING_TIME
        $str.= '`OPENING_TIME` = "' . self::getOPENING_TIME() . '",';

        // CONTACT_NAME
        $str.= '`CONTACT_NAME` = "' . self::getCONTACT_NAME() . '",';

        // CONTACT_NUMBER
        $str.= '`CONTACT_NUMBER` = "' . self::getCONTACT_NUMBER() . '",';

        // PASSWORD
        $str.= '`PASSWORD` = "' . self::getPASSWORD() . '",';

        // PROVINCE
        $str.= '`PROVINCE` = "' . self::getPROVINCE() . '",';

        // CITY
        $str.= '`CITY` = "' . self::getCITY() . '",';

        // COUNTY
        $str.= '`COUNTY` = "' . self::getCOUNTY() . '",';

        // DETAIL
        $str.= '`DETAIL` = "' . self::getDETAIL() . '",';

        // LNG
        $str.= '`LNG` = "' . self::getLNG() . '",';

        // LAT
        $str.= '`LAT` = "' . self::getLAT() . '",';

        // FOOD_GROUPS_ORDER
        $str.= '`FOOD_GROUPS_ORDER` = "' . self::getFOOD_GROUPS_ORDER() . '",';

        // IS_ISLAMIC
        $str.= '`IS_ISLAMIC` = "' . self::getIS_ISLAMIC() . '",';

        // CREATED_ON
        $str.= '`CREATED_ON` = "' . self::getCREATED_ON() . '",';

        // CREATED_BY
        $str.= '`CREATED_BY` = "' . self::getCREATED_BY() . '",';

        // UPDATED_ON
        $str .= "UPDATED_ON = now()," ;

        // UPDATED_BY
        $str.= '`UPDATED_BY` = "' . self::getUPDATED_BY(). '"';
        return $str;
    }



    public function toUpdateWhere(){
        $str = "";
        $str .= "`RESTAURANT_ID` = '" . self::getRESTAURANT_ID()."'";
        return $str;
    }

}


